<template>
  <div class="searchtop">
    <van-search
      class="txt1"
      v-model="value"
      show-action
      shape="round"
      placeholder="清风抽纸"
      @search="onSearch"
    >
      <template #left>
        <van-icon name="arrow-left" @click="goback()" />
      </template>
      <template #action>
        <div @click="onSearch" class="btnsearch">搜索</div>
      </template>
    </van-search>
  </div>
</template>

<script>
export default {
  data() {
    return {
      value: "",
      list: [],
    };
  },

  methods: {
    onSearch() {
      if (this.$route.path == "/searchlist") {
        this.$emit("changekeyword", this.value);
      } else {
        this.$router.push({
          name: "searchlist",
          params: {
            data: this.value,
          },
        });
      }
     this.$emit("search",this.value)
    },
    goback() {
      this.$router.go(-1);
    },
  },
};
</script>

<style scoped>
.btnsearch {
  background-color: red;
  color: #fff;
  padding: 0 0.2778rem;
  border-radius: 0.3333rem;
}
</style>